import { Controller, Get, Post, Body, Patch, Param, Delete, ParseIntPipe, Query } from '@nestjs/common';
import { UserService } from './user.service';
import { CreateUserDto } from './dto/create-user.dto';
import { UpdateUserDto } from './dto/update-user.dto';
import { QueryUserDto } from './dto/query-user.dto';
import { UserEntity } from './entities/user.entity'
import { PaginationResult } from '@/common/interface/pagination.interface'
import { Public } from '@/modules/auth/auth.decorator';

@Public() //JWT校验白名单装饰器
@Controller('user')
export class UserController {
  constructor(private readonly userService: UserService) { }

  @Post()
  create(@Body() dto: CreateUserDto) {
    return this.userService.create(dto);
  }

  @Get()
  findAll(@Query() query) {
    return this.userService.findAll(query);
  }

  @Get(':id')
  findOne(@Param('id',ParseIntPipe) id: number) {
    return this.userService.findOne(id); //＋号可以把字符串转为数字类型
  }

  @Patch(':id')
  update(@Param('id',ParseIntPipe) id: number, @Body() dto) {
    return this.userService.update(id, dto);
  }

  @Delete(':id')
  remove(@Param('id',ParseIntPipe) id: number) {
    return this.userService.remove(id);
  }
}
